﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;

namespace 网络流
{
    struct  StructTest
    {
        public string strTest1;
        public string strtest2;
        public int testInt;
    }

    class EventTestClass
    {
        private event EventHandler<EventArgs> TestEvent;

        public EventTestClass()
        {
            TestEvent += EventTestClass_TestEvent;
        }

        private void EventTestClass_TestEvent(object sender, EventArgs e)
        {
            for (int i = 0; i < 1000; i++)
            {
            Console.WriteLine($"EventTestClass_TestEvent__{i}");
            }
        }

        public void StartEvent()
        {
            
            TestEvent.Invoke(null,new  EventArgs());

            for (int i = 0; i < 1000; i++)
            {
                Console.WriteLine($"StartEvent__{i}");
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Testdelegate();
            //TestStruct();
            //TestDic();
            Console.ReadLine();
        }

        private static void Testdelegate()
        {
            EventTestClass test = new EventTestClass();
            test.StartEvent();

            for (int i = 0; i < 1000; i++)
            {
                Console.WriteLine($"Testdelegate__{i}");
            }
        }

        private static void TestStruct()
        {
            StructTest[] sTests = new StructTest[3];
            for (int i = 0; i < 3; i++)
            {
                sTests[i].strTest1 = $"test1__{i}";
                sTests[i].strtest2 = $"test2__{i}";
                sTests[i].testInt = i;

            }

            foreach (var structTest in sTests)
            {
                Console.WriteLine(structTest.strTest1);
                Console.WriteLine(structTest.strtest2);
                Console.WriteLine(structTest.testInt);

            }
        }

        private static void TestDic()
        {
            Dictionary<string, TestClass> test = new Dictionary<string, TestClass>();
            test.Add("11",new TestClass()
                );
            test["11"].Wr();

            var testItem = test["11"];
            testItem.TestInt1 = 10;
            testItem.TestStr1 = "haha";

            test["11"].Wr();
        }
    }

    struct TestClass
    {
        public string TestStr1;
        public int TestInt1;

        public void Wr()
        {
            Console.WriteLine($"string:{TestStr1},int:{TestInt1}");
        }
    }


}
